home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Tools - Objects / MacApp / MacApp 3.0a2 / Libraries / UTabBehaviors.cp < prev    next >
Encoding:
Text File  |  1991-05-01  |  3.4 KB  |  154 lines  |  [TEXT/MPS ]

  1. #ifndef __UTabBehaviors__
  2. #include <UTabBehaviors.h>
  3. #endif
  4.  
  5. #ifndef __UEvent__
  6. #include <UEvent.h>
  7. #endif
  8.  
  9. #ifndef __UApplication__
  10. #include <UApplication.h>
  11. #endif
  12.  
  13. #ifndef __UWindow__
  14. #include <UWindow.h>
  15. #endif
  16.  
  17. #ifndef __UMacAppUtilities__
  18. #include <UMacAppUtilities.h>
  19. #endif
  20.  
  21. /////////////
  22. // TTabber //
  23. /////////////
  24.  
  25. //--------------------------------------------------------------------------------------------------
  26. #pragma segment MAOpen
  27.  
  28. pascal void TTabber::Initialize()
  29. {
  30.     inherited::Initialize();
  31.     fRecursive = TRUE;
  32.     fFoundCurrent = FALSE;
  33. }
  34.  
  35. //--------------------------------------------------------------------------------------------------
  36. #pragma segment MAOpen
  37.  
  38. pascal void TTabber::ITabber(Boolean recursive)
  39. {
  40.     this->IBehavior();
  41.     fRecursive = recursive;
  42. }
  43.  
  44. //--------------------------------------------------------------------------------------------------
  45. #pragma segment MARes
  46.  
  47. pascal void TTabber::DoKeyCommand(TToolboxEvent* event)
  48. {
  49.     if (event && event->fCharacter == chTab)
  50.         this->Tab(event->fShiftKey);
  51.     else
  52.         inherited::DoKeyCommand(event);
  53. }
  54.  
  55. //--------------------------------------------------------------------------------------------------
  56. #pragma segment MARes
  57.  
  58. pascal void TTabber::Tab(Boolean tabBackward)
  59. {
  60.     this->Reset();
  61.     
  62.     this->FindTargets();
  63.     if (fNext == NULL)
  64.         fNext = fFirst;
  65.     if (fPrevious == NULL)
  66.         fPrevious = fLast;
  67.     if (tabBackward)
  68.         fNext = fPrevious;
  69.     if (fNext)
  70.         fNext->BeTarget();
  71. }
  72.  
  73. //--------------------------------------------------------------------------------------------------
  74. #pragma segment MARes
  75.  
  76. pascal void TTabber::Reset()
  77. {
  78.     fFirst = NULL;
  79.     fLast = NULL;
  80.     fNext = NULL;
  81.     fPrevious = NULL;
  82.     fFoundCurrent = FALSE;
  83. }
  84.  
  85. //--------------------------------------------------------------------------------------------------
  86. #pragma segment MARes
  87.  
  88. pascal void TTabber::FindSubViewTargets(TView* parent)
  89. {
  90.     CSubViewIterator iter(parent);
  91.  
  92.     for (TView* aView = iter.FirstSubView(); iter.More(); aView = iter.NextSubView())
  93.     {
  94.         if (aView->IsEnabled() && aView->IsShown() && aView->WantToBecomeTarget())
  95.         {
  96.             if (fFirst == NULL)
  97.                 fFirst = aView;
  98.             fLast = aView;
  99.             if (aView == gApplication->GetTarget())
  100.                 fFoundCurrent = TRUE;
  101.             else if (fFoundCurrent && (fNext == NULL))
  102.                 fNext = aView;
  103.             if (!fFoundCurrent)
  104.                 fPrevious = aView;
  105.         }
  106.         if (fRecursive)
  107.             this->FindSubViewTargets(aView);
  108.     }
  109. }
  110.  
  111. //--------------------------------------------------------------------------------------------------
  112. #pragma segment MARes
  113.  
  114. pascal void TTabber::FindTargets()
  115. {
  116.     this->SubClassResponsibility();
  117. }
  118.  
  119. ///////////////////
  120. // TWindowTabber //
  121. ///////////////////
  122.  
  123. //--------------------------------------------------------------------------------------------------
  124. #pragma segment MARes
  125.  
  126. pascal void TWindowTabber::FindTargets()    // Override
  127. {
  128.     if ((qNeedsProcessMgr) || (gConfiguration.hasProcessMgr) || (!gApplication->IsDeskAccessory(FrontWindow())))
  129.     {
  130.         CWMgrIterator iter;
  131.         
  132.         for (WindowPtr aWinPtr = iter.FirstWMgrWindow(); iter.More(); aWinPtr = iter.NextWMgrWindow())
  133.         {
  134.             TWindow* aWindow = gApplication->WMgrToWindow(aWinPtr);
  135.         
  136.             if ((aWindow) && (aWindow->IsShown()) && (aWindow->IsActive()))
  137.                 this->FindSubViewTargets(aWindow);
  138.         }
  139.     }
  140.     
  141. }
  142.  
  143. /////////////////
  144. // TViewTabber //
  145. /////////////////
  146.  
  147. //--------------------------------------------------------------------------------------------------
  148. #pragma segment MARes
  149.  
  150. pascal void TViewTabber::FindTargets()    // Override
  151. {
  152.     this->FindSubViewTargets( (TView*) fOwner);
  153. }
  154.